#ifndef PROCESSGRID_H_INCLUDED

#define PROCESSGRID_H_INCLUDED

//accumulated data
//initialize them in processGrid_init()
//update them in processGrid_accumulate()
//finalize them (print) in processGrid_finalize()
struct processGrid_accumulatedData {
	//example content
	unsigned long long valueCount[81][9];
};

//per grid data
//initialize and populate them in processGrid_getPerGridData()
struct processGrid_perGridData {
	//example content
	int cellValues[81];
};

void processGrid_init(processGrid_accumulatedData &a);
void processGrid_getPerGridData(char *g, processGrid_perGridData &d);
void processGrid_accumulate(processGrid_accumulatedData &a, processGrid_perGridData &d);
void processGrid_finalize(processGrid_accumulatedData &a);

//example implementation: count how much times each cell contain appropriate digit
void processGrid_init(processGrid_accumulatedData &a) {
	for(int i = 0; i < 81; i++) {
		for(int j = 0; j < 9; j++) {
			a.valueCount[i][j] = 0;
		}
	}
}

void processGrid_getPerGridData(char *g, processGrid_perGridData &d) {
	for(int i = 0; i < 81; i++) {
		d.cellValues[i] = g[i] - 1; //map 1..9 to 0..8
	}
}

void processGrid_accumulate(processGrid_accumulatedData &a, processGrid_perGridData &d) {
	for(int i = 0; i < 81; i++) {
		a.valueCount[i][d.cellValues[i]]++; //increment d[i]'th possibility for i'th cell
	}
}

void processGrid_finalize(processGrid_accumulatedData &a) {
	printf("\t1\t2\t3\t4\t5\t6\t7\t8\t9");
	for(int i = 0; i < 81; i++) {
		printf("\n%d", i);
		for(int j = 0; j < 9; j++) {
			printf("\t%llu", a.valueCount[i][j]);
		}
	}
	printf("\n");
}

#endif //PROCESSGRID_H_INCLUDED

